package com.tx.review.string_;

/**
 * @author ：tx
 * @version:
 */
public class StringPoolDemo {
    public static void main(String[] args) {
        /*String a = "hello";
        String b = "hello";
        //字符串常量池中只有一份，所以为true
        System.out.println(a == b);*/

/*
        String s1 = "hello";
        String s2 = new String("hello");
        System.out.println(s1 == s2);   //false*/



        /*String s1 = new String("hello ") + new String("world");
        s1.intern();
        String s2 = "hello world";
        System.out.println(s1 == s2);   //true*/


        String s1 = "hello ";
        String s2 = "world";
        String s3 = s1 + s2;
        String s4 = "hello world";
        System.out.println(s3 == s4);
    }
}
